using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using DAL;
using DTO;
namespace BUS
{
    public class tbDealBUS
    {
        public static void Insert(tbDeal deal)
        {
            tbDealDAL dealDAL = new tbDealDAL();
            dealDAL.Insert(deal);
        }
        public static void Update(tbDeal deal)
        {
            tbDealDAL dealDAl = new tbDealDAL();
            dealDAl.Update(deal);
        }
        public static void Delete(String iD)
        {
            tbDealDAL blDAl = new tbDealDAL();
            blDAl.Delete(iD);
        }
        public static tbDealCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbDealDAL dealDAL = new tbDealDAL();
            return dealDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbDealCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDealDAL blDAL = new tbDealDAL();
            return blDAL.Get(cri.Criter, 0, 0, tbDealColumns.madeal.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbDeal GetByID(String iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbDealColumns.madeal.ToString(), Condition.EQUAL, iD);
            tbDealDAL dealDAL = new tbDealDAL();
            tbDealCollection dealCollection = dealDAL.Get(cri.Criter, 0, 0, tbDealColumns.madeal.ToString(), OrderDirection.ASC.ToString(), out total);
            if (dealCollection.Count > 0)
                return dealCollection[0];
            return null;
        }
        public static tbDealCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDealDAL dealDAL = new tbDealDAL();
            return dealDAL.Get(cri.Criter, 1, number, tbDealColumns.madeal.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbDealCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDealDAL dealDAL = new tbDealDAL();
            return dealDAL.Get(cri.Criter, 1, number, tbDealColumns.madeal.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
